/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package client.controllers;

import client.data.DobbelstenenPaneel;
import java.util.LinkedList;
import java.util.Random;
import org.apache.log4j.Logger;

/**
 *
 * @author Gunnar Verhulst
 */
public class BoggleController {
    private static Logger logger = Logger.getLogger(BoggleController.class);
    private static BoggleController instance = new BoggleController();
    private String[][] spelbord;
    private LinkedList<String> letters;
    private Random generator;
    
    
    private BoggleController(){
        spelbord = new String[4][4];
        generator = new Random();
        letters = new LinkedList<String>();
    }
    
    public static BoggleController getInstance() {
        return instance;
    }
    
    public void reset(){
        letters.clear();
        setSpelbord(new String[4][4]);
        vulOpSpelBord();
    }
    
    private void vulOpSpelBord(){   
        DobbelstenenPaneel dp = new DobbelstenenPaneel();
        setSpelbord(dp.geefBord());
        
    }

    public String[][] getSpelbord() {
        return spelbord;
    }
    
    public String getXMLSpelbord(){
        String lijn;
        lijn="<bord>";
        for(int i=0; i < 4; i++){
            lijn+="<rij>";
            lijn+=i;
            lijn+="</rij>";
            for(int j=0; j < 4; j++){
                lijn+="<kolom>";
                lijn+=j;
                lijn+="</kolom>";
                lijn+="<boggleLetter>";
                lijn+=spelbord[i][j];
                lijn+="</boggleLetter>";
            }
        }
        lijn+="</bord>";
        return lijn;
    }

    public void setSpelbord(String[][] spelbord) {
        this.spelbord = spelbord;
    }

}
